﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.lib.webuploader._0._1._5.server
{
    public partial class Upload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string basePath = Server.MapPath("~/UpLoad/");
            string name = string.Empty;
            HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            //如果目录不存在，则创建目录
            List<string> List = new List<string>();
            if (files != null)
            {
                if (!Directory.Exists(basePath))
                {
                    Directory.CreateDirectory(basePath);
                }
                for (int i = 0; i < files.Count; i++)
                {
                    files[i].SaveAs(basePath + DateTime.Now.ToString("yyyy-MM-ddHHmmss") + files[i].FileName);
                    List.Add("/UpLoad/" + DateTime.Now.ToString("yyyy-MM-ddHHmmss") + files[i].FileName);
                }
                Response.Write(JsonConvert.SerializeObject(List));
            }
        }
    }
}